package Experiment4;

import java.util.*;

public class LinkedListRunner {
    public static void main(String[] args){
        LinkedList<String> List1 = new LinkedList<>();
        List1.add("aaa");
        List1.add("bbb");
        List1.add("ccc");
        List1.add("ddd");
        List1.add("eee");
        List1.add("fff");
        List1.add("ggg");
        List1.add("hhh");
        List1.add("iii");
        ListIterator<String> L1 = List1.listIterator();
        while(L1.hasNext())
            System.out.println(L1.next());
        while (L1.hasPrevious()) { 
            char flag = L1.previous().charAt(0);
            if(flag=='a'||flag=='e'||flag=='i'||flag=='o'||flag=='u')
                L1.remove();
        }
        while(L1.hasNext()){
            System.out.println(L1.next());
        }
        HashMap<String,String> name = new HashMap<String,String>();
        name.put("Sue","Bob,Jose,Alex and Cathy");
        name.put("Cathy","Bob and Alex");
        name.put("Bob","Alex,Jose and Jerry");
        Scanner input = new Scanner(System.in);
        System.out.println("Please input the name you wanna search.");
        String n = input.next();
        System.out.println(n+" is friend with"+name.getOrDefault(n,",the name is not in this HashMap"));
    }
}

